/**
 * 
 */
package ar.edu.utn.frsf.cidisi.ginet.generation.preferformalizationpage;

import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;

import ar.edu.utn.frsf.cidisi.ginet.formalization.FormalCBPLanguage;
import ar.edu.utn.frsf.cidisi.ginet.formalization.FormalizationPackage;

public class EMFModelLoad {
	public FormalCBPLanguage load() {
		// Initialize the model
		FormalizationPackage.eINSTANCE.eClass();

		// Register the XMI resource factory for the .website extension
		
		String name = Activator.getDefault().getPreferenceStore()
	            .getString("PATH");

		Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
		Map<String, Object> m = reg.getExtensionToFactoryMap();
		m.put("formalization", new XMIResourceFactoryImpl());

		// Obtain a new resource set
		ResourceSet resSet = new ResourceSetImpl();

		// Get the resource
		Resource resource = resSet
				.getResource(
						URI.createURI("platform:/resource/ar.edu.utn.frsf.cidisi.ginet.test/model/upcolbpip-wscdl.formalization"),
						true);
		// Get the first model element and cast it to the right type, in my
		// example everything is hierarchical included in this first node
		FormalCBPLanguage myWeb = (FormalCBPLanguage) resource.getContents()
				.get(0);
		return myWeb;
	}

}
